package book;

import java.util.Objects;

public class Book {
    private String name;
    private String author;
    private String category;
    private int price;
    private boolean isBorrowed;

    public Book(String name, String author, String category, int price) {
        this.name = name;
        this.author = author;
        this.category = category;
        this.price = price;
    }

    @Override
    public String toString() {
        return "Book{" +
                name +
                ", 作者：" + author +
                ", 类别：" + category +
                ", 价格：" + price +
                ", 是否被借出：" + (isBorrowed ? "已被借出" : "未被借出") +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Book book = (Book) o;
        return price == book.price && isBorrowed == book.isBorrowed && Objects.equals(name, book.name) && Objects.equals(author, book.author) && Objects.equals(category, book.category);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public boolean isBorrowed() {
        return isBorrowed;
    }

    public void setBorrowed(boolean borrowed) {
        isBorrowed = borrowed;
    }
}
